<%@page contentType="text/plain;charset=GBK"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.Set"%>
<%@page import="java.util.List"%>
<%@page import="javax.management.MBeanServerFactory"%>
<%@page import="javax.management.MBeanServer"%>
<%@page import="javax.management.ObjectName"%>
<%@page import="javax.management.MBeanInfo"%>
<%@page import="javax.management.MBeanAttributeInfo"%>


<%
	out.clear();

	List<MBeanServer> mbeanServers = MBeanServerFactory.findMBeanServer(null);

	MBeanServer mbeanServer = null;
	if (mbeanServers.size() > 0) {
		for (MBeanServer ibeanServer : mbeanServers) {		
			if ("jboss".equals(ibeanServer.getDefaultDomain())) {
				mbeanServer = ibeanServer;
				break;
			}
		}
	}

	try {

		String protocol = "HTTP/1.1";
		String scheme = "http";
		
		out.println("protocol= " + protocol);
		out.println("scheme= " + scheme);
		
		Set<ObjectName> objectNames = mbeanServer.queryNames(new ObjectName("jboss.web:type=Connector,*"), null);
		for (ObjectName objectName : objectNames) {
			String protocolAttribute = String.valueOf(mbeanServer.getAttribute(objectName, "protocol"));
			String schemeAttribute = String.valueOf(mbeanServer.getAttribute(objectName, "scheme"));

			if (protocol.equals(protocolAttribute) && scheme.equals(schemeAttribute)) {
				String address = String.valueOf(mbeanServer.getAttribute(objectName, "address"));
				String port = String.valueOf(mbeanServer.getAttribute(objectName, "port"));

				out.println("address= " + address);
				out.println("port= " + port);

			}
		}
	} catch (Exception e) {
		out.println("Error - " + e.toString());
		return;
	}
%>